package stud.mpgame.flash.net.gameobject;

import stud.mpgame.network.UserObject;

import stud.mpgame.snapshot.IGameObject;

/**
 * ...
 * @author sydy[sydyM6@gmail.com]
 */

class TestGameObject implements IGameObject, extends UserObject {
	
	private var value:Int;

	public function new(value:Int) {
		super();
		this.value = value;
	}
	
	public function getID():Int {
		return 1;
	}
	
	public function getValue():Int {
		return value;
	}
	
	public function setValue(value:Int):Void {
		this.value = value;
	}
	
	public function interpolate(deltaTime:Int, gameObject:IGameObject, interpolationDeltaTime:Int):Void {
		//trace("TestGameObject interpolate");
		var differenceValue:Int = cast(gameObject, TestGameObject).getValue() - value;
		var addition:Int = Std.int(deltaTime * differenceValue * 1. / interpolationDeltaTime);
		if (Math.abs(differenceValue) == 1)
			addition = differenceValue;
		//trace("addition: " + addition + "\n" + deltaTime + "; " + differenceValue + "; " + interpolationDeltaTime);
		value += addition;
	}
	
	public function extrapolate(deltaTime:Int):Void {
		
	}
	
	public function synchronize(gameObject:IGameObject):Void {
		
	}
	
}